/*
 * All header file for c language MUST be include : in extern "C" { }
 */
extern "C" {
#include "../src/uni_black_board.c"
}

H2UNIT(black_board) {
  void setup() {
    BlackBoardInit();
  }
  void teardown() {
    BlackBoardFinal();
  }
};

H2CASE(black_board, "read and write") {
  int ret;
  int value;
  ret = BbRead("key1", &value);
  H2EQ_MATH(-1, ret);
  ret = BbWrite("key1", 10);
  H2EQ_MATH(0, ret);
  ret = BbRead("key1", &value);
  H2EQ_MATH(0, ret);
  H2EQ_MATH(10, value);
  ret = BbWrite("key1", -1);
  H2EQ_MATH(0, ret);
  ret = BbRead("key1", &value);
  H2EQ_MATH(0, ret);
  H2EQ_MATH(-1, value);
  ret = BbWrite("key2", -1);
  H2EQ_MATH(0, ret);
  ret = BbRead("key2", &value);
  H2EQ_MATH(0, ret);
  H2EQ_MATH(-1, value);
  ret = BbWrite("key22", -1);
  H2EQ_MATH(0, ret);
  ret = BbRead("key22", &value);
  H2EQ_MATH(0, ret);
  H2EQ_MATH(-1, value);
}
